home *** CD-ROM | disk | FTP | other *** search
- property calcButton, theBrain, contributionField, interestField, ContributionValue, InterestValue, InterestFieldSelected, currentField, acceptKeys, interestCursor, contributionCursor, DELETE_KEY
-
- on tabKey me
- set InterestFieldSelected to not InterestFieldSelected
- if InterestFieldSelected then
- set currentField to interestField
- set the visible of sprite interestCursor to 1
- set the visible of sprite contributionCursor to 0
- set the text of interestField to " "
- set InterestValue to 0
- setInterestRate(theBrain, 0)
- turnOff(calcButton)
- else
- set currentField to contributionField
- set the visible of sprite contributionCursor to 1
- set the visible of sprite interestCursor to 0
- set the text of contributionField to " "
- set ContributionValue to 0
- setMonthlyContribution(theBrain, 0)
- turnOff(calcButton)
- end if
- set acceptKeys to 1
- end
-
- on keyPress me, xKey
- if acceptKeys then
- case xKey of
- BACKSPACE:
- if InterestFieldSelected then
- set interestString to the text of interestField
- if InterestValue = 0 then
- if floatp(InterestValue) then
- if the last char in interestString = "." then
- set InterestValue to 0
- set interestString to " "
- else
- delete char -30000 of interestString
- end if
- else
- set interestString to " "
- end if
- else
- if floatp(InterestValue) then
- if the last char in interestString = "." then
- set InterestValue to integer(InterestValue * 10) / 10
- set interestString to string(InterestValue)
- else
- delete char -30000 of interestString
- end if
- else
- if InterestValue < 10 then
- set interestString to " "
- set InterestValue to 0
- else
- delete char -30000 of interestString
- end if
- end if
- end if
- set tempString to interestString
- if tempString contains "," then
- set whichPos to offset(tempString, ",")
- put "." into char whichPos of tempString
- end if
- set InterestValue to value(tempString)
- else
- set ContributionValue to ContributionValue / 10
- if ContributionValue <> 0 then
- set contributionString to moneyFormat(ContributionValue)
- else
- set contributionString to " "
- end if
- end if
- DELETE_KEY, "c", "C":
- if InterestFieldSelected then
- set InterestValue to 0
- set interestString to " "
- else
- set ContributionValue to 0
- set contributionString to " "
- end if
- RETURN:
- mouseEvent(calcButton, #mouseEnter)
- mouseEvent(calcButton, #mouseDown)
- mouseEvent(calcButton, #mouseUp)
- mouseEvent(calcButton, #mouseGone)
- otherwise:
- if InterestFieldSelected then
- set interestString to the text of interestField
- if the number of chars in interestString < 5 then
- if the key = "," then
- if floatp(InterestValue) then
- beep()
- else
- if InterestValue = 0 then
- set interestString to "0,"
- else
- put "," after interestString
- end if
- set InterestValue to float(InterestValue)
- end if
- else
- if xKey >= "0" then
- if xKey <= "9" then
- if not floatp(InterestValue) then
- if InterestValue <> 0 then
- put xKey after interestString
- else
- set interestString to xKey
- end if
- else
- put xKey after interestString
- end if
- else
- beep()
- end if
- end if
- end if
- set InterestValue to value(interestString)
- end if
- else
- if xKey >= "0" then
- if xKey <= "9" then
- if ContributionValue < 1000 then
- set ContributionValue to (ContributionValue * 10) + value(xKey)
- if ContributionValue <> 0 then
- set contributionString to moneyFormat(ContributionValue)
- else
- set contributionString to " "
- end if
- else
- beep()
- end if
- else
- beep()
- end if
- else
- beep()
- end if
- end if
- end case
- if InterestFieldSelected then
- if not voidp(interestString) then
- set the text of interestField to interestString
- end if
- else
- if not voidp(contributionString) then
- set the text of contributionField to contributionString
- end if
- end if
- setInterestRate(theBrain, InterestValue)
- setMonthlyContribution(theBrain, ContributionValue)
- if the text of interestField = " " then
- turnOff(calcButton)
- else
- if the text of contributionField = " " then
- turnOff(calcButton)
- else
- turnON(calcButton)
- end if
- end if
- put InterestValue
- put ContributionValue
- end if
- end
-
- on selectInterestField me
- set InterestFieldSelected to 0
- tabKey(me)
- end
-
- on selectContributionField me
- set InterestFieldSelected to 1
- tabKey(me)
- end
-
- on refuseKeys me
- set acceptKeys to 0
- set the visible of sprite interestCursor to 0
- set the visible of sprite contributionCursor to 0
- end
-
- on new me
- set contributionField to member "Contribution Input"
- set interestField to member "Interest Input"
- set ContributionValue to 0
- set InterestValue to 0
- set InterestFieldSelected to 0
- set currentField to contributionField
- set DELETE_KEY to 127
- set interestCursor to 24
- set contributionCursor to 23
- puppetSprite(interestCursor, 1)
- puppetSprite(contributionCursor, 1)
- set the visible of sprite interestCursor to 0
- set the visible of sprite contributionCursor to 0
- set InterestFieldSelected to 1
- set acceptKeys to 0
- return me
- end
-
- on linkUp me, xButton, xBrain
- set calcButton to xButton
- set theBrain to xBrain
- setInterestRate(theBrain, InterestValue)
- setMonthlyContribution(theBrain, ContributionValue)
- end
-